<template>
	<view>
		<button @click="logi">登录</button>
		<image :src="appoo.avatarUrl"></image>
		<!-- <img :src="{{appoo.avatarUrl}}" alt=""> -->
		<text>{{appoo.nickName}}</text>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				appoo: []
			};
		},
		methods: {
			logi() {
				let vm = this
				uni.getUserProfile({
					desc: '用于完善会员资料',
					success: (res1) => {
						console.log(res1, "res1");
						uni.setStorageSync('userinfo', res1.userInfo)
						let {
							nickName,
							avatarUrl
						} = res1.userInfo
						// console.log(nickName,avatarUrl);
						let appid = 'wx472c4a8d0d10be83'
						let secret = 'e1350189b580a1bd375b75789a2dbddf'
						uni.login({
							success(res) {
								console.log(res);
								let {
									code
								} = res
								if (res.code) {
									uni.request({
										url: 'https://meituan.thexxdd.cn/api/wx_login',
										method: 'post',
										data: {
											nickName,
											avatarUrl,
											code,
											appid,
											secret
										}
									}).then(res => {
										console.log(res[1], '000');
										vm.appoo = res[1].data.data
										uni.setStorageSync('user',vm.appoo)
									})
								}
							}
						})
					}
				})

			}
		},
	}
</script>

<style lang="scss">

</style>
